package com.jar.exercise.多线程.线程池.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class NewScheduledThreadPool {
	public static void main(String[] args) {
		ScheduledExecutorService schedule = Executors.newScheduledThreadPool(5);
		System.out.println("开始");
		schedule.schedule(
			() -> {
				System.out.println(Thread.currentThread().getName() + "延时1秒执行");
			}, 1, TimeUnit.SECONDS
		);
		schedule.scheduleAtFixedRate(() -> {
			System.out.println(Thread.currentThread().getName() +"xxx");
		}, 1, 3, TimeUnit.SECONDS);
		schedule.scheduleAtFixedRate(() -> {
			System.out.println(Thread.currentThread().getName() +"qqq");
		}, 1, 1, TimeUnit.SECONDS);
	}
}
